<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>班次添加</title>
    <%@include file="common/head.jsp" %>
    <%@include file="common/loginstate.jsp" %>
    <script type="text/javascript" src="${staticPath}/js/popup.js"></script>
    <script language="JavaScript" src="${staticPath}/js/public.js" type="text/javascript"></script>
    <link href="${staticPath}/qtimages/images/apple-touch-icon.png" rel="apple-touch-icon">
    <link href="${staticPath}/qtimages/lib/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="${staticPath}/qtimages/lib/animate/animate.min.css" rel="stylesheet">
    <link href="${staticPath}/qtimages/lib/ionicons/css/ionicons.min.css" rel="stylesheet">
    <link href="${staticPath}/qtimages/lib/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet">
    <link href="${staticPath}/qtimages/lib/magnific-popup/magnific-popup.css" rel="stylesheet">
    <link href="${staticPath}/qtimages/lib/ionicons/css/ionicons.min.css" rel="stylesheet">
    <link href="${staticPath}/qtimages/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="${staticPath}/qtimages/css/style.css" rel="stylesheet">
    <link rel="stylesheet" href="${staticPath}/qtimages/css/custom.css">

    <script type="text/javascript">
        //文件上传
        function upx(id) {
            var pop=new Popup({ contentType:1,isReloadOnClose:false,width:400,height:200});
            pop.setContent("contentUrl","${contextPath}/common/upload/?id="+id);
            pop.setContent("title","文件上传");
            pop.build();
            pop.show();
        }
        // 添加班次
        function banciAdd() {
			var bianhao = $("#bianhao").length > 0 ? $('#bianhao').val().trim():null;
			if(("#bianhao").length > 0 && bianhao == "")
			{
				alert("please input:编号");
			    $('#bianhao').focus();
				return false;
			}
			var leibieid=$('#leibieid').val().trim();
			var qishizhan = $("#qishizhan").length > 0 ? $('#qishizhan').val().trim():null;
			if(("#qishizhan").length > 0 && qishizhan == "")
			{
				alert("please input:起始站");
			    $('#qishizhan').focus();
				return false;
			}
			var zhongdianzhan = $("#zhongdianzhan").length > 0 ? $('#zhongdianzhan').val().trim():null;
			if(("#zhongdianzhan").length > 0 && zhongdianzhan == "")
			{
				alert("please input:终点站");
			    $('#zhongdianzhan').focus();
				return false;
			}
			var qishishijian = $("#qishishijian").length > 0 ? $('#qishishijian').val().trim():null;
			if(("#qishishijian").length > 0 && qishishijian == "")
			{
				alert("please input:起始时间");
			    $('#qishishijian').focus();
				return false;
			}
			var daodashijian = $("#daodashijian").length > 0 ? $('#daodashijian').val().trim():null;
			if(("#daodashijian").length > 0 && daodashijian == "")
			{
				alert("please input:到达时间");
			    $('#daodashijian').focus();
				return false;
			}
			var riqi = $("#riqi").length > 0 ? $('#riqi').val().trim():null;
			if(("#riqi").length > 0 && riqi == "")
			{
				alert("please input:日期");
			    $('#riqi').focus();
				return false;
			}
			var jiage = $("#jiage").length > 0 ? $('#jiage').val().trim():null;
			if(("#jiage").length > 0 && jiage == "")
			{
				alert("please input:价格");
			    $('#jiage').focus();
				return false;
			}
			var shuliang = $("#shuliang").length > 0 ? $('#shuliang').val().trim():null;
			if(("#shuliang").length > 0 && shuliang == "")
			{
				alert("please input:票数");
			    $('#shuliang').focus();
				return false;
			}
			var beizhu = $("#beizhu").length > 0 ? $('#beizhu').val().trim():null;
			if(("#beizhu").length > 0 && beizhu == "")
			{
				alert("please input:备注");
			    $('#beizhu').focus();
				return false;
			}

            var param = {
				'bianhao':bianhao,
				'leibieid':leibieid,
				'qishizhan':qishizhan,
				'zhongdianzhan':zhongdianzhan,
				'qishishijian':qishishijian,
				'daodashijian':daodashijian,
				'riqi':riqi,
				'jiage':jiage,
				'shuliang':shuliang,
				'beizhu':beizhu,

            };
            $.ajax({
                type: 'post',
                url: '${basePath}/banciAddOrUpdate',
                dataType: "json",
                contentType:"application/json",
                data : JSON.stringify(param),
                success: function (resp) {
                    if (resp.success) {
                        alert("添加成功！");
                        //window.location.href = "${contextPath}/banciManaMyQian";
                    } else {
                        alert(resp.message);
                    }
                }
            });
        }
    </script>
</head>

<body>
<%@ include file="qttop.jsp" %>
<%@ include file="bht.jsp" %>
<main id="main">
    <section id="services" class="wow fadeInUp">
        <div class="container">
            <div class="section-header">
                <h2>◇◆ 班次添加 ◆◇</h2>
            </div>
            <div class="row">

                <form  name="formAdd" id="formAdd">
                    <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bordercolor="#00FFFF"
                           style="border-collapse:collapse" class="newsline">
		<tr>
			<td>
				编号:
			</td>
            <td>
                <input type="text" name="bianhao" id="bianhao" size="70px"/>
            </td>

		</tr>
		<tr>
			<td>
				类别:
			</td>
            <td>
                <select name="leibieid" id="leibieid" style="border:solid 1px #000000; color:#666666"></select>
            </td>
            <script type="text/javascript">
                $.get(basePath + '/leibieAll/', function(resp) {
                    if (resp.success) {
                        if(resp.data!=null){
                            var list = resp.data;
                            for(var i=0; i<list.length; i++){
                                var info = list[i];
                                $("#leibieid").append("<option value='"+info.id+"' >" + info.mingcheng + "</option>");
                            }
                        }
                    }else {
                        alert(resp.message);
                    }
                });
            </script>

		</tr>
		<tr>
			<td>
				起始站:
			</td>
            <td>
                <input type="text" name="qishizhan" id="qishizhan" size="70px"/>
            </td>

		</tr>
		<tr>
			<td>
				终点站:
			</td>
            <td>
                <input type="text" name="zhongdianzhan" id="zhongdianzhan" size="70px"/>
            </td>

		</tr>
		<tr>
			<td>
				起始时间:
			</td>
            <td>
                <input type="text" name="qishishijian" id="qishishijian" style="border:1px solid #cccccc;" readonly="readonly" size="25px" value="<%=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())%>" />
            </td>

		</tr>
		<tr>
			<td>
				到达时间:
			</td>
            <td>
                <input type="text" name="daodashijian" id="daodashijian" style="border:1px solid #cccccc;" readonly="readonly" size="25px" value="<%=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())%>" />
            </td>

		</tr>
		<tr>
			<td>
				日期:
			</td>
            <td>
                <input type="text" name="riqi" id="riqi" style="border:1px solid #cccccc;" class="Wdate" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" onClick="WdatePicker({'dateFmt':'yyyy-MM-dd'})" size="15px" value="<%=new SimpleDateFormat("yyyy-MM-dd").format(new Date())%>" />
            </td>

		</tr>
		<tr>
			<td>
				价格:
			</td>
            <td>
                <input type="number" name="jiage" id="jiage" value="0" size="70px"/>
            </td>

		</tr>
		<tr>
			<td>
				票数:
			</td>
            <td>
                <input type="number" name="shuliang" id="shuliang" value="0" size="70px"/>
            </td>

		</tr>
		<tr>
			<td>
				备注:
			</td>
            <td>
                <input type="text" name="beizhu" id="beizhu" size="70px"/>
            </td>

		</tr>

                        <tr>
                            <td>&nbsp;</td>
                            <td>
                                <input type="button" name="Submit" value="提交" onClick="banciAdd();"
                                       class="content-form-signup"/>
                                <input type="button" value="返回" onClick="javascript:history.back()"/>
                                <%--<input type="reset" name="reset" value="重置" class="content-form-signup"/>--%>
                            </td>
                        </tr>
                    </table>
                </form>

            </div>
        </div>
    </section>
    <%@ include file="qtdown.jsp" %>
</main>
</body>
</html>

